package com.hylink.api;

import com.hylink.model.User;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping(value="/api/users")
@Api(value = "测试API", description = "测试操作")
public class SwaggerAPI {


    /*
     *  http://localhost:8080/api-doc/index.html
     */

    /**
     *
     * @return
     */
    @ApiOperation(value = "获取用户信息", httpMethod = "POST", notes = "应用系统执行该方法获取全部用户信息")
    @RequestMapping(method= RequestMethod.GET)
    public List<User> getUsers(){
        List<User> list=new ArrayList<User>();

        User user=new User();
        user.setName("hello");
        list.add(user);

        User user2=new User();
        user.setName("world");
        list.add(user2);
        return list;
    }

    @ApiOperation(value="根据id获取用户信息",notes="用户id ")
    @RequestMapping(value="/{name}",method= RequestMethod.GET)
    public User getUserById(@PathVariable String name){
        User user=new User();
        user.setName("hello world");
        return user;
    }
}
